function createArr(start,end){
    const res=[]
    while(start<=end){
        res.push(start)
        start++
    }
    return res
}

// console.log(createArr(1,5));

function getSum(i,j){
    return (i+j)*(j-i+1)/2
}


function solve(sum){
    const ans = []
    let middle=Math.ceil(sum/2)
    for(let i=1;i<middle;i++){
        for(let j=middle;j>i;j--){
            if(getSum(i,j)===sum){
                ans.push(createArr(i,j))
                break
            }else if(getSum(i,j)<sum){
                break
            }
        }
    }
    return ans
}

console.log(solve(15));
console.log(solve(4));
console.log(solve(5));
console.log(solve(10));